<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	<ui:define name="content">
		<p:panel header="#{msg.loaivthh_title}">
			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{LoaiVTHHBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":loaiVTHHForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>
			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{LoaiVTHHBean.downloadFileCSV}" ajax="false">
					<p:fileDownload value="#{LoaiVTHHBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="loaiVTHHForm">
				<p:growl id="growforFile" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
				<p:treeTable var="loaivthh" id="dataTable"
					value="#{LoaiVTHHBean.loaivthhRoot}"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="#{msg.danhsachloaivthh}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px"
								update=":addloaiVTHHForm:display" value="#{msg.themmoi}"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{LoaiVTHHBean.notifyAdd}"
								onclick="PF('loaivthhDialog').show();">
							</p:commandButton>
						</div>

					</f:facet>

					<p:column headerText="#{msg.maloaivthh}">#{loaivthh.maLoai}  </p:column>

					<p:column headerText="#{msg.tenloaivthh}">  #{loaivthh.tenLoai}   </p:column>

					<p:column headerText="#{msg.dienGiai}">  #{loaivthh.dienGiai}   </p:column>

					<p:column style="width:60px;text-align: center;"
						headerText="#{msg.table_actions}">
						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-pencil" update=":addloaiVTHHForm:display"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							action="#{LoaiVTHHBean.notifyEdit(loaivthh)}"
							oncomplete="PF('loaivthhDialog').show();">

						</p:commandButton>
						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="PF('confirmRemove').show();">
							<f:setPropertyActionListener value="#{loaivthh}"
								target="#{LoaiVTHHBean.selectedloaivthh}" />
						</p:commandButton>
					</p:column>

				</p:treeTable>

				<p:dialog id="confirmRemove" header="#{msg.confirm}"
					widgetVar="confirmRemove" resizable="false">
					<table>
						<tr>
							<td><h:outputText value="#{msg.confirm_text}:" /></td>
							<td align="right"><p:commandButton value="#{msg.okButton}"
									actionListener="#{LoaiVTHHBean.removeloaivthh}"
									update=":loaiVTHHForm" oncomplete="PF('confirmRemove').hide();" /></td>
						</tr>

					</table>
				</p:dialog>
			</h:form>
			<h:form id="addloaiVTHHForm">
				<p:dialog id="dialog" header="#{msg.modify}" modal="true"
					widgetVar="loaivthhDialog" resizable="false">

					<p:panel id="display">
						<table>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="maloaivthh" value="#{msg.maloaivthh}" /></td>
								<td><p:inputText styleClass="inputText" required="true" readonly="#{LoaiVTHHBean.edit}"
										requiredMessage="#{msg.maloaivthh}: #{msg.valuerequired}"
										id="maloaivthh" value="#{LoaiVTHHBean.maloaivthh}">

									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="tenloaivthh" value="#{msg.tenloaivthh}" /></td>
								<td><p:inputText styleClass="inputText" id="tenloaivthh"
										value="#{LoaiVTHHBean.tenloaivthh}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.thuocloaivthh}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{LoaiVTHHBean.thuocloaivthh}" filter="true"
										filterMatchMode="contains">
										<f:selectItem itemLabel="#{msg.root}" itemValue="root"></f:selectItem>
										<f:selectItems value="#{LoaiVTHHBean.listloaivthh}"
											var="selectItem" itemLabel="#{selectItem.tenLoai}"
											itemValue="#{selectItem.maLoai}" />
									</p:selectOneMenu></td>

							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px" for="diengiai"
										value="#{msg.dienGiai}" /></td>
								<td><p:inputText styleClass="inputText" id="diengiai"
										value="#{LoaiVTHHBean.diengiai}">

									</p:inputText></td>
							</tr>
							<tr>
								<td></td>
								<td align="right"><p:commandButton value="#{msg.save}"
										actionListener="#{LoaiVTHHBean.save}"
										update=":loaiVTHHForm :addloaiVTHHForm:display"
										oncomplete="if(args.opSuccess) PF('loaivthhDialog').hide()"></p:commandButton></td>
							</tr>
						</table>
					</p:panel>
				</p:dialog>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
